<div class="clear"></div>
<%= form_for @task,
     :url => create_task_order_url,
     :remote => true,
     :method => :post do |f|
 %>
<div class='new_or_edit_task'>
  <h6>增加一项关联任务</h6>
  <dl>
    <dt></dt>
    <dd>
      <%= f.text_field :name, :class => :task_name %>
      <%= f.hidden_field :order_item_id %>
      <%= f.hidden_field :feed_id %>
    </dd>
  </dl>
  <dl>
    <dt>该任务指派给谁？</dt>
    <dd>
      <%= f.select :executor_id, User.active.workmates.collect { |user| [user.nick_name, user.id]} %>
    </dd>
  </dl>
  <dl>
    <dt>何时到期？</dt>
    <dd>
     <%= f.text_field :due_on, :class => :date %>
      <script>
        $('#task_due_on').datepicker({
          showButtonPanel: true
        });
      </script>
    </dd>
  </dl>
  <dl>
    <dt></dt>
    <dd>
      <%= f.check_box :visible_scope, {}, 'everyone', 'only_myself'%> <%= label :task, :visible_scope, '让所有同事可以见到该任务' %>
    </dd>
  </dl>
  <dl>
    <dt>任务类型</dt>
    <dd id='task_type_by_input_<%=@task.feed.id%>' class='task_type_by_input'>
    <%= f.text_field :type_name, :id => "text_task_type_#{@task.feed.id}", :class => :task_type %>
    <%= link_to_function '选择',"$('#task_type_by_select_#{@task.feed.id}').show();$('#task_type_by_input_#{@task.feed.id}').hide()", :title => '从已有的类型中挑选一项', :class => 'task_type_switch task_type_switch_from_select' %>
    </dd>    
    <dd id='task_type_by_select_<%=@task.feed.id%>' class='task_type_by_select'>
    <%=select_tag :sel_type_name, task_type, :class => :task_types, :id => "sel_type_name_#{@task.feed.id}"%>
    <%= link_to_function '输入',"$('#task_type_by_input_#{@task.feed.id}').show();$('#task_type_by_select_#{@task.feed.id}').hide();$('#text_task_type_#{@task.feed.id}').select()", :title => '没有合适的，还是我自己输入吧', :class => 'task_type_switch task_type_switch_from_input' %>
    <script type="text/javascript" charset="utf-8">
      $('#sel_type_name_<%=@task.feed.id%>').change(function() {
        $('#text_task_type_<%=@task.feed.id%>').val($(this).val());
      })
    </script>
    </dd>
  </dl>  
  <div class='clear'></div>
  <hr/>
  <dl>
    <dt></dt>
    <dd>
      <%= submit_tag '保存' %><%= link_to '返回',tasks_orders_url(:feed_id => task.feed_id), :remote => true, :method => :get, :class => :button %>      
    </dd>
  </dl>  
  <%end%>
</div>
<div class="clear"></div>